package com.ruoyi.dormitory.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dormitory.mapper.TbDormitoryMemberMapper;
import com.ruoyi.dormitory.domain.TbDormitoryMember;
import com.ruoyi.dormitory.service.ITbDormitoryMemberService;

/**
 * 宿舍成员Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-28
 */
@Service
public class TbDormitoryMemberServiceImpl implements ITbDormitoryMemberService
{
    @Autowired
    private TbDormitoryMemberMapper tbDormitoryMemberMapper;

    /**
     * 查询宿舍成员
     *
     * @param id 宿舍成员主键
     * @return 宿舍成员
     */
    @Override
    public TbDormitoryMember selectTbDormitoryMemberById(String id)
    {
        return tbDormitoryMemberMapper.selectTbDormitoryMemberById(id);
    }

    /**
     * 查询宿舍成员列表
     *
     * @param tbDormitoryMember 宿舍成员
     * @return 宿舍成员
     */
    @Override
    public List<TbDormitoryMember> selectTbDormitoryMemberList(TbDormitoryMember tbDormitoryMember)
    {
        return tbDormitoryMemberMapper.selectTbDormitoryMemberList(tbDormitoryMember);
    }

    /**
     * 新增宿舍成员
     *
     * @param tbDormitoryMember 宿舍成员
     * @return 结果
     */
    @Override
    public int insertTbDormitoryMember(TbDormitoryMember tbDormitoryMember)
    {
//        tbDormitoryMember.setCreateTime(DateUtils.getNowDate());
         tbDormitoryMember.setId(UUID.randomUUID().toString().replaceAll("-", ""));
        return tbDormitoryMemberMapper.insertTbDormitoryMember(tbDormitoryMember);
    }

    /**
     * 修改宿舍成员
     *
     * @param tbDormitoryMember 宿舍成员
     * @return 结果
     */
    @Override
    public int updateTbDormitoryMember(TbDormitoryMember tbDormitoryMember)
    {
        tbDormitoryMember.setUpdateTime(DateUtils.getNowDate());
        return tbDormitoryMemberMapper.updateTbDormitoryMember(tbDormitoryMember);
    }

    /**
     * 批量删除宿舍成员
     *
     * @param ids 需要删除的宿舍成员主键
     * @return 结果
     */
    @Override
    public int deleteTbDormitoryMemberByIds(String[] ids)
    {
        return tbDormitoryMemberMapper.deleteTbDormitoryMemberByIds(ids);
    }

    /**
     * 删除宿舍成员信息
     *
     * @param id 宿舍成员主键
     * @return 结果
     */
    @Override
    public int deleteTbDormitoryMemberById(String id)
    {
        return tbDormitoryMemberMapper.deleteTbDormitoryMemberById(id);
    }
}
